package gui;

import gui.menu.classDiagram.*;
import gui.menu.edit.NewItem;
import gui.menu.edit.RedoItem;
import gui.menu.edit.UndoItem;
import gui.menu.file.ConfigureExporters;
import gui.menu.file.ExportToXmlItem;
import gui.menu.file.ImportFromXmlItem;
import gui.menu.stateDiagram.*;
import gui.menu.view.ViewBand;
import gui.menu.view.ViewMenu;
import org.pushingpixels.flamingo.api.common.JCommandButton;
import org.pushingpixels.flamingo.api.common.JCommandToggleButton;
import org.pushingpixels.flamingo.api.common.StringValuePair;
import org.pushingpixels.flamingo.api.common.icon.EmptyResizableIcon;
import org.pushingpixels.flamingo.api.common.icon.ImageWrapperResizableIcon;
import org.pushingpixels.flamingo.api.ribbon.*;
import org.pushingpixels.flamingo.api.ribbon.resize.CoreRibbonResizePolicies;
import org.pushingpixels.flamingo.api.ribbon.resize.RibbonBandResizePolicy;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.*;


/**
 * User: Szymon Kudzia
 * Date: 13.05.13
 * Time: 19:55
 */
public class Window extends JRibbonFrame implements ActionListener{
	protected DiagramsDrawingPanel drawingPanel;
	protected ConfigureExporters configureExporters;

	public Window(String windowTitle, DiagramsDrawingPanel drawingPanel, ConfigureExporters configureExporters) {
		super(windowTitle);

		this.drawingPanel = drawingPanel;
		this.configureExporters = configureExporters;

		this.setSize(640, 580);

		this.setApplicationIcon(ImageWrapperResizableIcon.getIcon(
				ClassLoader.getSystemClassLoader().getResource("icons/icon.png"),
				new Dimension(32, 32)));

		RibbonApplicationMenu menu = new RibbonApplicationMenu();
		menu.addMenuEntry(new ImportFromXmlItem());
		menu.addMenuEntry(new ExportToXmlItem());

		RibbonApplicationMenuEntryPrimary export = new RibbonApplicationMenuEntryPrimary(
				ImageWrapperResizableIcon.getIcon(
									ClassLoader.getSystemClassLoader().getResource("icons/export.png"),
									new Dimension(16, 16)),
				"Export", null, JCommandButton.CommandButtonKind.POPUP_ONLY
		);

		configureExporters.addExporters(export);

		menu.addMenuEntry(export);

		JFlowRibbonBand cd = new JFlowRibbonBand("Class diagram", new EmptyResizableIcon(10));

		cd.setResizePolicies(Arrays.<RibbonBandResizePolicy>asList(
				new CoreRibbonResizePolicies.FlowTwoRows(cd.getControlPanel())));

		cd.addFlowComponent(new AddMemberItem());
		cd.addFlowComponent(new AddMethodItem());
		cd.addFlowComponent(new AddImplementationItem());
		cd.addFlowComponent(new AddInterfaceItem());
		cd.addFlowComponent(new AddClassItem());

		cd.addFlowComponent(new DeleteMemberItem());
		cd.addFlowComponent(new DeleteMethodItem());
		cd.addFlowComponent(new DeleteImplementationItem());
		cd.addFlowComponent(new DeleteEntityItem());



		JFlowRibbonBand sd = new JFlowRibbonBand("State diagram", new EmptyResizableIcon(10));

		sd.setResizePolicies(Arrays.<RibbonBandResizePolicy>asList(
				new CoreRibbonResizePolicies.FlowTwoRows(sd.getControlPanel())));

		sd.addFlowComponent(new AddStateItem());
		sd.addFlowComponent(new AddTransitionItem());
		sd.addFlowComponent(new AddConditionalTransitionItem());
		sd.addFlowComponent(new DeleteStateItem());
		sd.addFlowComponent(new DeleteTransitionItem());

		this.getRibbon().setApplicationMenu(menu);
		this.getRibbon().addTask(new RibbonTask("Actions", cd, sd, new ViewBand()));

		this.getRibbon().addTaskbarComponent(new NewItem());
		this.getRibbon().addTaskbarComponent(new UndoItem());
		this.getRibbon().addTaskbarComponent(new RedoItem());

		getContentPane().add(new JScrollPane(this.drawingPanel), BorderLayout.CENTER);
	}

	@Override
	public void actionPerformed(ActionEvent actionEvent) {
	}
}
